<?php


namespace app\community\oauth2\Entities;


use DateTimeImmutable;
use League\OAuth2\Server\Entities\AuthCodeEntityInterface;
use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Entities\ScopeEntityInterface;

class AuthCodeEntity implements AuthCodeEntityInterface
{

    // 重定向地址
    protected string $redirectUri;
    // 令牌标识符
    protected string $identifier;
    // 用户标识符
    protected mixed $userIdentifier;
    // token过期时间
    protected DateTimeImmutable $expiryDateTime;
    // 客户端信息
    protected ClientEntityInterface $client;

    protected array $scope = [];

    public function getRedirectUri(): string
    {
        // TODO: Implement getRedirectUri() method.
        return $this->redirectUri;
    }

    public function setRedirectUri($uri)
    {
        // TODO: Implement setRedirectUri() method.
        $this->redirectUri = $uri;
    }

    public function getIdentifier()
    {
        // TODO: Implement getIdentifier() method.
        return $this->identifier;
    }

    public function setIdentifier($identifier)
    {
        // TODO: Implement setIdentifier() method.
        $this->identifier = $identifier;
    }

    public function getExpiryDateTime(): DateTimeImmutable
    {
        // TODO: Implement getExpiryDateTime() method.
        return $this->expiryDateTime;
    }

    public function setExpiryDateTime(DateTimeImmutable $dateTime)
    {
        // TODO: Implement setExpiryDateTime() method.
        $this->expiryDateTime = $dateTime;
    }

    public function setUserIdentifier($identifier)
    {
        // TODO: Implement setUserIdentifier() method.
        $this->userIdentifier = $identifier;
    }

    public function getUserIdentifier()
    {
        // TODO: Implement getUserIdentifier() method.
        return $this->userIdentifier;
    }

    public function getClient(): ClientEntityInterface
    {
        // TODO: Implement getClient() method.
        return $this->client;
    }

    public function setClient(ClientEntityInterface $client)
    {
        // TODO: Implement setClient() method.
        $this -> client = $client;
    }

    public function addScope(ScopeEntityInterface $scope)
    {
        // TODO: Implement addScope() method.
        $this->scope[] = $scope;
    }

    public function getScopes(): array
    {
        // TODO: Implement getScopes() method.
        return $this->scope;
    }
}